﻿<!doctype html>
<html>
<head>
    <title>SpreadJS - Tag Action Support</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    
    <link href="../../../external/spreadjs/css/gcspread.sheets.excel2013white.9.40.20161.0.css" rel="stylesheet" type="text/css" />

    <script src="../../../external/external/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../../external/spreadjs/gcspread.sheets.all.9.40.20161.0.min.js"></script>

    <script id="scriptInit" type="text/javascript">
        /*code_begin*/
        $(document).ready(function () {
            var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"), { sheetCount: 1 });
            initSpread(spread);
        });

        function initSpread(spread) {
            var spreadNS = GcSpread.Sheets,
                sheet = spread.sheets[0];

            // set drag fill type to CopyCells in order to demo tag will be copied
            sheet.defaultDragFillType(spreadNS.AutoFillType.CopyCells);

            sheet.setArray(3, 1, [["a", 1], ["b", 2], ["c", 3]]);

            sheet.setTag(3, 1, "Tag for 'a'");
            sheet.setTag(4, 2, "Number tag");
            sheet.setTag(4, 1, { row: 12, column: 2 });
            sheet.setTag(5, 2, new Date(Date.UTC(2014, 7, 12)));

            sheet.bind(spreadNS.Events.EnterCell, function () {
                var tag = sheet.getTag(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex());

                if (tag == null) {
                    $("#txtTag").val("");
                }
                else if (typeof tag === "string") {
                    $("#txtTag").val(tag);
                } else {
                    $("#txtTag").val(JSON.stringify(tag));
                }
            });
        }
        /*code_end*/
    </script>

</head>
<body>
    <div class="sample-turtorial">
        <div id="ss" style="width: 100%; height: 420px; border: 1px solid gray;"></div>
        <div class="demo-options">
            <div class="option-row">
                <label for="txtTag">Tag: </label>
                <input type="text" id="txtTag" style="width: 200px" />
            </div>
        </div>
        <div class="demo-options">
            <div class="option-row">
                <p style="background-color:lavender;padding: 4px;">
                    Tags are set for some cells in B4:C6, select a cell to get its tag data in custom string format.<br />
                    ** The defaultDragFillType is set to CopyCells in this demo.
                </p>
            </div>
        </div>
    </div>
</body>
</html>
